package com.omkarpatil.learningjpa2.mapping.basic.secondarytable;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.SecondaryTable;
import javax.persistence.SecondaryTables;
import javax.persistence.Table;
import javax.persistence.PrimaryKeyJoinColumn;

@Entity(name="SecondaryTableEmployee")
@Table(name="basic_sec_tab_emp")
@SecondaryTables({
        @SecondaryTable(name="basic_sec_tab_emp_phone"),
        @SecondaryTable(name="basic_sec_tab_emp_email", 
            pkJoinColumns=@PrimaryKeyJoinColumn(name="emp_id"))
})
public class Employee implements Serializable {
	private int id;
	private String name;
	private String landlineNumber;
	private String mobileNumber;
	private String officeEmail;
	private String personalEmail;
	
	public Employee() {}

	public Employee(String name, String landlineNumber, String mobileNumber,
			String officeEmail, String personalEmail) {
		this.name = name;
		this.landlineNumber = landlineNumber;
		this.mobileNumber = mobileNumber;
		this.officeEmail = officeEmail;
		this.personalEmail = personalEmail;
	}

	@Id @GeneratedValue
	public int getId() {
		return id;
	}

	private void setId(int id) {
		this.id = id;
	}

	@Column(nullable = false, length = 30)
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	@Column(table = "basic_sec_tab_emp_phone", nullable = false, length = 10)
	public String getLandlineNumber() {
		return landlineNumber;
	}

	public void setLandlineNumber(String landlineNumber) {
		this.landlineNumber = landlineNumber;
	}

	@Column(table = "basic_sec_tab_emp_phone", nullable = false, length = 10)
	public String getMobileNumber() {
		return mobileNumber;
	}

	public void setMobileNumber(String mobileNumber) {
		this.mobileNumber = mobileNumber;
	}

	@Column(table="basic_sec_tab_emp_email", nullable = false, length = 30)
	public String getOfficeEmail() {
		return officeEmail;
	}

	public void setOfficeEmail(String officeEmail) {
		this.officeEmail = officeEmail;
	}

	@Column(table="basic_sec_tab_emp_email", nullable = false, length = 30)
	public String getPersonalEmail() {
		return personalEmail;
	}

	public void setPersonalEmail(String personalEmail) {
		this.personalEmail = personalEmail;
	}
}
